package com.bawei.house_web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bawei.house_service.bean.House;
import com.bawei.house_service.service.HouseService;
import com.github.pagehelper.PageInfo;

@Controller
//视图层
public class HouseController {
	
	@Autowired
	private HouseService service;
	
	@RequestMapping("/list")
	public String selects(Model model,@RequestParam(defaultValue="1")Integer pageNum,@RequestParam(defaultValue="2") Integer pageSize,String name,String status) {
		PageInfo<House> info=service.selects(pageNum,pageSize,name,status);
		
		//存到作用域
		model.addAttribute("info", info);
		
		return "list";
	}
	@RequestMapping("del")
	@ResponseBody
	public boolean del(Integer id) {
		try {
			service.del(id);
			return true;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return false;
		}
		
		
	}
	
}	

